package cn.yzfy.api;

import cn.dev33.satoken.annotation.SaIgnore;
import cn.yzfy.common.model.dto.LoginInputDTO;
import cn.yzfy.common.model.dto.LoginOutputDTO;
import cn.yzfy.service.IAuthService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import lombok.AllArgsConstructor;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 一朝风月
 * @date 2025/9/11 21:14
 * @Code 面向注解面向卿，终无解释再无你
 * @description 用户授权接口
 */
@Tag(name = "认证接口", description = "认证相关接口,登录、注销、获取用户权限等")
@RestController
@RequestMapping("/auth")
@RequiredArgsConstructor
public class AuthUserController {
    private final IAuthService authService;


    public String captcha() {
        return authService.captcha();
    }


    @SaIgnore
    @Operation(summary = "登录接口", description = "登录接口")
    @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "200", description = "ok")
    @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "420", description = "账号或密码错误")
    @ApiResponse(responseCode = "430", description = "账号不存在")
    @PostMapping(value = "/login", produces = MediaType.APPLICATION_JSON_VALUE)
    public LoginOutputDTO login(@Validated @RequestBody LoginInputDTO inputDTO,
                                HttpServletRequest request) {
         return authService.login(inputDTO, request);
    }



























































    
}
